import React from "react";
import {createBrowserRouter, Navigate} from "react-router-dom";
import Admin from "../pages/Admin/admin";
import Login from "../pages/Login/login.jsx";

import Home from "../pages/Home/home";
import Category from "../pages/Category/category";
import Product from "../pages/Product/product";
import Role from "../pages/Role/role";
import User from "../pages/User/user";
import Bar from "../pages/Charts/bar";
import Line from "../pages/Charts/line";
import Pie from "../pages/Charts/pie";
import ProductHome from "../pages/Product/home";
import ProductAddUpdate from "../pages/Product/add-update";
import ProductDetail from "../pages/Product/detail";

// 存在 dom结构标签 文件类型采用tsx
const router = createBrowserRouter([
  {
    path: "/",
    element: <Admin />,
    children: [
      {
        path: '/',
        element: <Navigate to='/home' />
      },
      {
        path: 'home',
        element: <Home />,
      },
      {
        path: "category",
        element: <Category />,
      },
      {
        path: "role",
        element: <Role />,
      },
      {
        path: "user",
        element: <User />,
      },
      {
        path: "product",
        element: <Product />,
        children: [{
          path: '',
          element: <ProductHome />
        },{
          path: 'add-update',
          element: <ProductAddUpdate />
        },{
          path: 'detail',
          element: <ProductDetail />
        }]
      },
      {
        path: "charts/bar",
        element: <Bar />,
      },
      {
        path: "charts/line",
        element: <Line />,
      },
      {
        path: "charts/pie",
        element: <Pie />,
      },
      // ... 其他子路由 ...
    ],
  },
  {
    path: "/login",
    element: <Login />,
  }
]);

export default router;
